package cors

import (
	"github.com/iris-contrib/middleware/cors"
	"github.com/jinzhu/configor"
	"github.com/kataras/iris"
)

var config = struct {
	Cors struct {
		Orings       []string
		Credentials  bool
		AllowMethods []string
	}
}{}

func Configurator(app *iris.Application) {
	configor.Load(&config, "conf/config.yml")

	app.WrapRouter(cors.WrapNext(cors.Options{
		AllowedOrigins:   config.Cors.Orings,
		AllowCredentials: config.Cors.Credentials,
	}))
}
